# import os
# size=0
# def get_dir_size(target_dir):
#     global size
#     d_list=os.listdir(target_dir)
#     print(d_list)
#     for f in d_list:
#         f=os.path.join(target_dir,f)
#         print(f,os.path.getsize(f))
#         size+=os.path.getsize(f)
#
#     return size
# dir_size=get_dir_size(r'C:\Program Files\JetBrains')
# print('总的大小：',dir_size)

# f=open(r'.\A','r')
# content=f.read(30)
# print(content)
# f.close()

#以下是随堂练习
# f=open('./A','r')
# # content=f.readline()
# # while len(content)>0:
# #     print(content)
# #     content=f.readline()
# # f.close()
# # print('-'*80)

# f=open('./b.txt','w')
# f.write('hello python\n')
# a=['hello java\n','hello php\n','hello c++\n']
# f.writelines(a)
# f.close()


# import os
# def copy_file(file1,file2):
#     '''
#     文件复制函数
#     :param file1:
#     :param file2:
#     :reture:
#     '''
#     f1=open(file1,'rb')
#     f2=open(file2,'wb')
#     content=f1.readline()
#     while len(content)>0:
#         f2.write(content)
#         content=f1.readline()
#     f1.close()
#     f2.close()
# copy_file('./b.txt','./c.txt')

# import os
# def copy_file(file1,file2):
#     f1=open(file1,'rb')
#     f2=open(file2,'wb')
#     content=f1.readline()
#     while len(content)>0:
#         f2.write(content)
#         content = f1.readline()
#     print('mission complete')
#     f1.close()
#     f2.close()
# # copy_file('./c.txt','./d.txt')

# def copy_path(dir1,dir2):
#     dlist=os.listdir(dir1)
#     os.mkdir(dir2)
# #     遍历所有文件并执行文件复制
#     for f in dlist:
#         # 为遍历的文件添加目录路径
#         file1=os.path.join(dir1,f) #源文件
#         file2=os.path.join(dir2,f) #目标
#         if os.path.isfile(file1): #判断是否是文件
#             copy_file(file1,file2) #调用写好的函数
#         if os.path.isdir(file1):
#             copy_path(file1,file2) #递归调用自己，来实现子目录的复制
# copy_path(r'C:\Program Files\JetBrains\1ST WEEK\第一周作业','./NewFile')